# Windows PowerShell 构建脚本

Write-Host "Building all shared libraries..." -ForegroundColor Cyan

# 定义库构建顺序（考虑依赖关系）
$libraries = @(
    "core",
    "common",
    "config",
    "database",
    "redis",
    "utils",
    "logging",
    "auth",
    "service-discovery",
    "email"
)

foreach ($lib in $libraries) {
    Write-Host "Building @tao-yan-kitchen/$lib..." -ForegroundColor Yellow

    # 切换到库目录并构建
    Set-Location "libs/$lib"
    npm run build

    if ($LASTEXITCODE -ne 0) {
        Write-Host "Failed to build @tao-yan-kitchen/$lib" -ForegroundColor Red
        exit 1
    }

    # 返回根目录
    Set-Location ../..

    Write-Host "Successfully built @tao-yan-kitchen/$lib" -ForegroundColor Green
}

Write-Host "All libraries built successfully!" -ForegroundColor Cyan